/**
 * Created by hcadmin on 16/10/9.
 */
$(function(){

    $(".call_back").hide();

    initLogModelList(localStorage.group_id,"-1","2");
    var dailyrecord_temp_id="";
    //点击跳转创建模板
    $(".log_nav_right").on('click',function(){
        window.location.href="createLogModel.html?whichpage=1&num_model="+num_model+"";
    });
    //点击展示"编辑","删除"
    $(document).on('click','.model_cell_big',function(){
        var display = $($(this).next()).css("display");
        if(display == "none"){
            $($(this).next()).css("display","block");
        }else{
            $($(this).next()).css("display","none");
        }
    });
    //点击编辑
    $(document).on('click','.hidden_part_icon_edit',function(){
        dailyrecord_temp_id     = $(this).attr("dailyrecord_temp_id");
        var sequence            = $(this).attr("sequence");
        var user_id             = $(this).attr("user_id");
        var group_id            = $(this).attr("group_id");
        var icon                = $(this).attr("icon");
        window.location.href="createLogModel.html?whichpage=1&dailyrecord_temp_id="+dailyrecord_temp_id+"&edit=1&sequence="+sequence+"&icon="+icon+"";
    });


    $(document).on('click','.hidden_part_icon_delete',function(){
        //debugger;
        dailyrecord_temp_id=$(this).attr("dailyrecord_temp_id");
        $(".call_back").show();
    });

    $(".cancel").on('click',function(){
        $(".call_back").hide();
    });
    $("#sure").on('click',function(){
        $(".call_back").hide();
        $.ajax({
            url:apiurl+"/dailyrecords/temp/"+dailyrecord_temp_id+"",
            type:"DELETE",
            success:function(d){

                var data = JSON.parse(d);
                if(data.code=="0"){
                    $(".call_back_success").text("删除成功");
                }else{
                    $(".call_back_success").text(data.msg);
                }
                $(".call_back_success").fadeIn(1000,function(){
                    window.location.reload();
                });
            }
        })
    });

    //点击删除
    //$(document).on('click','.hidden_part_icon_delete',function(){
    //
    //
    //
    //
    //
    //
    //});
});